Skip to main content

How to modify the camera rendering distance by script using Java

How to modify the Camera rendering distance by script using Java


In your Java class, do the following:

public class YourClass extends Component {

// value to control the Camera rendering distance
public float distance = 500f; // select in properties

// creates a new SUIButton
public SUIButton button; // select in properties

// creates a new Camera
public Camera camera; // select in properties

@Override
public void start() {

}

@Override
public void repeat() {

// checking if the button was pressed
if (button.isDown()) {

// changing the Camera rendering distance if the conditional is true
camera.setRenderDistance(distance);
}
}
}